<template>
    <!-- 这个组件通过Pinia store控制全局通知 -->
    <!-- 无需模板内容，因为直接使用Element Plus的ElNotification -->
  </template>
  
  <script lang="ts" setup>
  import { watch } from 'vue'
  import { useNotificationStore } from '@/stores/notification'
  import { ElNotification } from 'element-plus'
  
  const notificationStore = useNotificationStore()
  
  watch(
    () => notificationStore.message,
    (newMsg) => {
      if (newMsg) {
        ElNotification({
          title: notificationStore.title,
          message: newMsg,
          type: notificationStore.type,
          duration: 3000,
          showClose: true
        })
        notificationStore.clear()
      }
    }
  )
  </script>